import 'dart:async';

import 'package:flutter/material.dart';
import 'package:time_fly/view/pages/microApp/clock.dart';

import '../view/pages/myHomePage.dart';

class Routes {
  //对应MaterialApp中的routes
  static Map<String, Widget Function(BuildContext)> getRoutes() {
    return <String, WidgetBuilder>{
      MyHomePage.name: (BuildContext context) => MyHomePage(),
      Clock.name: (BuildContext context) => Clock(),
    };
  }

  //主页 加载优先级1
  static Widget home() {
    return Clock();
  }

  // 初始化路由 加载优先级2
  static String initialRoute() {
    return Clock.name;
  }

  static MaterialPageRoute onGenerateRoute(RouteSettings settings) {
    var routes = <String, WidgetBuilder>{
      // 'launch': (BuildContext context) => LanuchView(),
    };
    WidgetBuilder builder = routes[settings.name];
    return MaterialPageRoute(builder: (ctx) => builder(ctx));
  }

  static MaterialPageRoute onUnknownRoute(RouteSettings settings) {
    var routes = <String, WidgetBuilder>{
      // 'launch': (BuildContext context) => LanuchView(),
    };
    WidgetBuilder builder = routes[settings.name];
    return MaterialPageRoute(builder: (ctx) => builder(ctx));
  }
}
